<?php

namespace app\adminapi\export;

use app\services\agent\AgentManageServices;

class AgentProductListExport extends BaseExport
{
    protected $header = [
        '商品', '分享次数', '访问人数', '访问-支付转化率', '成交金额(元)', '支付佣金(元)'
    ];


    public function createData(array $where)
    {
        $time = $where['time'] ?? [];
        $store_name = $where['store_name'] ?? '';
        $order_value = $where['order_value'] ?? 0;
        $order_type = $where['order_type'] ?? 0;
        $limit = $where['limit'] ?? 15;

        $list = app()->make(AgentManageServices::class)->productList(
            $time,
            $store_name,
            $order_value,
            $order_type,
            $limit
        )['list'];

        $data = [];

        foreach ($list as $item) {
            $data[] = [
                ($item['product']['store_name'] ?? '') . ' ' . $item['product']['suk'],
                $item['total_share_nums'] ?? '',
                $item['total_view_people_nums'] ?? '',
                $item['view_pay_rate'] ?? '',
                $item['total_deal_amount'] ?? '',
                $item['total_total_commission'] ?? ''
            ];
        }
    }
}